home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / NET / IRDA / IRDA.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  7KB  |  233 lines

  1. /*********************************************************************
  2.  *                
  3.  * Filename:      irda.h
  4.  * Version:       
  5.  * Description:   
  6.  * Status:        Experimental.
  7.  * Author:        Dag Brattli <dagb@cs.uit.no>
  8.  * Created at:    Tue Dec  9 21:13:12 1997
  9.  * Modified at:   Tue Apr  6 20:31:08 1999
  10.  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  11.  * 
  12.  *     Copyright (c) 1998 Dag Brattli, All Rights Reserved.
  13.  *      
  14.  *     This program is free software; you can redistribute it and/or 
  15.  *     modify it under the terms of the GNU General Public License as 
  16.  *     published by the Free Software Foundation; either version 2 of 
  17.  *     the License, or (at your option) any later version.
  18.  *  
  19.  *     Neither Dag Brattli nor University of Troms° admit liability nor
  20.  *     provide warranty for any of this software. This material is 
  21.  *     provided "AS-IS" and at no charge.
  22.  *     
  23.  ********************************************************************/
  24.  
  25. #ifndef NET_IRDA_H
  26. #define NET_IRDA_H
  27.  
  28. #include <linux/config.h>
  29. #include <linux/skbuff.h>
  30. #include <linux/kernel.h>
  31.  
  32. #include <net/irda/qos.h>
  33. #include <net/irda/irqueue.h>
  34.  
  35. #ifndef TRUE
  36. #define TRUE 1
  37. #endif
  38.  
  39. #ifndef FALSE 
  40. #define FALSE 0
  41. #endif
  42.  
  43. #define ALIGN __attribute__((aligned))
  44. #define PACK __attribute__((packed))
  45.  
  46. /* use 0 for production, 1 for verification, >2 for debug */
  47. #ifdef CONFIG_IRDA_DEBUG
  48.  
  49. extern __u32 irda_debug;
  50.  
  51. #define IRDA_DEBUG 0
  52.  
  53. #define DEBUG(n, args...) if (irda_debug >= (n)) printk( KERN_DEBUG args)
  54. #define ASSERT(expr, func) \
  55. if(!(expr)) { \
  56.         printk( "Assertion failed! %s,%s,%s,line=%d\n",\
  57.         #expr,__FILE__,__FUNCTION__,__LINE__); \
  58.         ##func}
  59. #else
  60. #define DEBUG(n, args...)
  61. #define ASSERT(expr, func)
  62. #endif /* CONFIG_IRDA_DEBUG */
  63.  
  64. /*
  65.  *  Magic numbers used by Linux/IR. Random numbers which must be unique to 
  66.  *  give the best protection
  67.  */
  68. #define IRTTY_MAGIC        0x2357
  69. #define LAP_MAGIC          0x1357
  70. #define LMP_MAGIC          0x4321
  71. #define LMP_LSAP_MAGIC     0x69333
  72. #define LMP_LAP_MAGIC      0x3432
  73. #define IRDA_DEVICE_MAGIC  0x63454
  74. #define IAS_MAGIC          0x007
  75. #define TTP_MAGIC          0x241169
  76. #define TTP_TSAP_MAGIC     0x4345
  77. #define IROBEX_MAGIC       0x341324
  78. #define HB_MAGIC           0x64534
  79. #define IRLAN_MAGIC        0x754
  80. #define IAS_OBJECT_MAGIC   0x34234
  81. #define IAS_ATTRIB_MAGIC   0x45232
  82.  
  83. #define IAS_DEVICE_ID 0x5342 
  84. #define IAS_PNP_ID    0xd342
  85. #define IAS_OBEX_ID   0x34323
  86. #define IAS_IRLAN_ID  0x34234
  87. #define IAS_IRCOMM_ID 0x2343
  88. #define IAS_IRLPT_ID  0x9876
  89.  
  90. typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW;
  91.  
  92. /* IrDA Socket */
  93. struct tsap_cb;
  94. struct irda_sock {
  95.     __u32 saddr;          /* my local address */
  96.     __u32 daddr;          /* peer address */
  97.  
  98.     struct ias_object *ias_obj;
  99.     struct tsap_cb *tsap; /* TSAP used by this connection */
  100.     __u8 dtsap_sel;       /* remote TSAP address */
  101.     __u8 stsap_sel;       /* local TSAP address */
  102.     
  103.     __u32 max_sdu_size_rx;
  104.     __u32 max_sdu_size_tx;
  105.     struct qos_info qos_tx;
  106.  
  107.     __u16 mask;           /* Hint bits mask */
  108.     __u16 hints;          /* Hint bits */
  109.  
  110.     __u32 ckey;           /* IrLMP client handle */
  111.     __u32 skey;           /* IrLMP service handle */
  112.  
  113.     int nslots;           /* Number of slots to use for discovery */
  114.  
  115.     struct sock *sk;
  116.     struct wait_queue *ias_wait;       /* Wait for LM-IAS answer */
  117.  
  118.     LOCAL_FLOW tx_flow;
  119.     LOCAL_FLOW rx_flow;
  120. };
  121.  
  122. /*
  123.  *  This type is used by the protocols that transmit 16 bits words in 
  124.  *  little endian format. A little endian machine stores MSB of word in
  125.  *  byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0] 
  126.  *  and LSB in byte[1].
  127.  */
  128. typedef union {
  129.     __u16 word;
  130.     __u8  byte[2];
  131. } __u16_host_order;
  132.  
  133. /*
  134.  *  Information monitored by some layers
  135.  */
  136. struct irda_statistics
  137. {
  138.         int     rx_packets;             /* total packets received       */
  139.         int     tx_packets;             /* total packets transmitted    */
  140.         int     rx_errors;              /* bad packets received         */
  141.         int     tx_errors;              /* packet transmit problems     */
  142.         int     rx_dropped;             /* no space in linux buffers    */
  143.         int     tx_dropped;             /* no space available in linux  */
  144.     int     rx_compressed;
  145.     int     tx_compressed;
  146.     int     rx_bytes;               /* total bytes received         */
  147.     int     tx_bytes;               /* total bytes transmitted      */
  148.  
  149.         int     multicast;              /* multicast packets received   */
  150.         int     collisions;
  151.     
  152.         /* detailed rx_errors: */
  153.         int     rx_length_errors;
  154.         int     rx_over_errors;         /* receiver ring buff overflow  */
  155.         int     rx_crc_errors;          /* recved pkt with crc error    */
  156.         int     rx_frame_errors;        /* recv'd frame alignment error */
  157.         int     rx_fifo_errors;         /* recv'r fifo overrun          */
  158.         int     rx_missed_errors;       /* receiver missed packet       */
  159.  
  160.         /* detailed tx_errors */
  161.         int     tx_aborted_errors;
  162.         int     tx_carrier_errors;
  163.         int     tx_fifo_errors;
  164.         int     tx_heartbeat_errors;
  165.         int     tx_window_errors;
  166. };
  167.  
  168. /* Misc status information */
  169. typedef enum {
  170.     STATUS_OK,
  171.     STATUS_ABORTED,
  172.     STATUS_NO_ACTIVITY,
  173.     STATUS_NOISY,
  174.     STATUS_REMOTE,
  175. } LINK_STATUS;
  176.  
  177. typedef enum {
  178.     LOCK_NO_CHANGE,
  179.     LOCK_LOCKED,
  180.     LOCK_UNLOCKED,
  181. } LOCK_STATUS;
  182.  
  183. typedef enum { /* FIXME check the two first reason codes */
  184.     LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */
  185.     LAP_NO_RESPONSE,       /* To many retransmits without response */
  186.     LAP_RESET_INDICATION,  /* To many retransmits, or invalid nr/ns */
  187.     LAP_FOUND_NONE,        /* No devices were discovered */
  188.     LAP_MEDIA_BUSY,
  189.     LAP_PRIMARY_CONFLICT,
  190. } LAP_REASON;
  191.  
  192. /*  
  193.  *  IrLMP disconnect reasons. The order is very important, since they 
  194.  *  correspond to disconnect reasons sent in IrLMP disconnect frames, so
  195.  *  please do not touch :-)
  196.  */
  197. typedef enum {
  198.     LM_USER_REQUEST = 1,  /* User request */
  199.     LM_LAP_DISCONNECT,    /* Unexpected IrLAP disconnect */
  200.     LM_CONNECT_FAILURE,   /* Failed to establish IrLAP connection */
  201.     LM_LAP_RESET,         /* IrLAP reset */
  202.     LM_INIT_DISCONNECT,   /* Link Management initiated disconnect */
  203.     LM_LSAP_NOTCONN,      /* Data delivered on unconnected LSAP */
  204.     LM_NON_RESP_CLIENT,   /* Non responsive LM-MUX client */
  205.     LM_NO_AVAIL_CLIENT,   /* No available LM-MUX client */
  206.     LM_CONN_HALF_OPEN,    /* Connection is half open */
  207.     LM_BAD_SOURCE_ADDR,   /* Illegal source address (i.e 0x00) */
  208. } LM_REASON;
  209. #define LM_UNKNOWN 0xff       /* Unspecified disconnect reason */
  210.  
  211. /*
  212.  *  Notify structure used between transport and link management layers
  213.  */
  214. struct notify_t {
  215.     int (*data_indication)(void *priv, void *sap, struct sk_buff *skb);
  216.     int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb);
  217.     void (*connect_confirm)(void *instance, void *sap, 
  218.                 struct qos_info *qos, __u32 max_sdu_size,
  219.                 struct sk_buff *skb);
  220.     void (*connect_indication)(void *instance, void *sap, 
  221.                    struct qos_info *qos, __u32 max_sdu_size,
  222.                    struct sk_buff *skb);
  223.     void (*disconnect_indication)(void *instance, void *sap, 
  224.                       LM_REASON reason, struct sk_buff *);
  225.     void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow);
  226.     void *instance; /* Layer instance pointer */
  227.     char name[16];  /* Name of layer */
  228. };
  229.  
  230. #define NOTIFY_MAX_NAME 16
  231.  
  232. #endif /* NET_IRDA_H */
  233.